home *** CD-ROM | disk | FTP | other *** search
- /* info.c - display, UpdateInfo */
-
- #include "mac/quickdraw.h"
- #include "mac/osintf.h"
- #include "mac/toolintf.h"
- #include "othello.h"
-
- #define CLICKMESSAGEID 2 /* Resource ID of "click to continue" */
-
- short inforect[] = { SCALE/2, SCALE * (BOARDSIZE + 1), 512, 512 };
- #define InfoRect (* (Rect *) inforect)
- #define GotoLine(l, p) MoveTo(InfoRect.left+(p), InfoRect.top+(l)*LINEHEIGHT)
- #define CENTER ((412 - SCALE*(BOARDSIZE + 1)) / 2)
- #define COLUMN1 (CENTER - (412 - SCALE*(BOARDSIZE + 1)) / 4)
- #define COLUMN2 (CENTER + (412 - SCALE*(BOARDSIZE + 1)) / 4)
-
- #define BCENTER (SCALE * (BOARDSIZE + 1) / 2)
- #define BBOTTOM (SCALE*(BOARDSIZE + 1) + LINEHEIGHT)
- short messrect[] = { BBOTTOM-LINEHEIGHT, 0, BBOTTOM, BCENTER*2 };
- #define MessRect (* (Rect *) messrect)
-
- char message[80] = "";
- char note1[80] = "";
- char note2[80] = "";
- char note3[80] = "";
-
- extern int nClicks;
-
-
- ClearMessages()
- {
- strcpy(message, "");
- strcpy(note1, "");
- strcpy(note2, "");
- strcpy(note3, "");
- }
-
-
-
- display(t) /* used to display info for t ticks for debugging */
- int t;
- {
- int ticks;
-
- UpdateInfo();
- ticks = TickCount() + t;
- while (TickCount() < ticks)
- ;
- }
-
-
-
- UpdateInfo()
- {
- GrafPtr saveport;
-
- /* BeginUpdate(myWindow); */
- GetPort(&saveport);
- SetPort(myWindow);
- DrawInfo();
- SetPort(saveport);
- /* EndUpdate(myWindow); */
- }
-
-
-
- DrawInfo()
- {
- char buf[512];
- MoveList moves;
- int nMoves;
- char *clickmessage;
-
- TextFont(InfoFont);
- TextSize(InfoSize);
- EraseRect(&InfoRect);
- EraseRect(&MessRect);
- GotoLine(1, CENTER - StringWidth(message)/2);
- DrawString(message);
- if (GameOver)
- strcpy(buf, "The game is over.");
- else
- sprintf(buf, "%s's move", colorName[curColor]);
- GotoLine(2, CENTER - StringWidth(buf)/2);
- DrawString(buf);
- TextFace(boldStyle);
- GotoLine(4, COLUMN1 - StringWidth("White")/2);
- DrawString("White");
- GotoLine(4, COLUMN2 - StringWidth("Black")/2);
- DrawString("Black");
- TextFace(italicStyle);
- GotoLine(5, COLUMN1 - StringWidth(playerName[player[stoneWhite]])/2);
- DrawString(playerName[player[stoneWhite]]);
- GotoLine(5, COLUMN2 - StringWidth(playerName[player[stoneBlack]])/2);
- DrawString(playerName[player[stoneBlack]]);
- TextFace(0);
- sprintf(buf, "%d", nStones[stoneWhite]);
- GotoLine(6, COLUMN1 - StringWidth(buf)/2);
- DrawString(buf);
- sprintf(buf, "%d", nStones[stoneBlack]);
- GotoLine(6, COLUMN2 - StringWidth(buf)/2);
- DrawString(buf);
- nMoves = FindMoves(curColor, GameBoard, moves, ALL);
- sprintf(buf, "%d choice%s", nMoves, nMoves == 1? "" : "s");
- GotoLine(8, CENTER - StringWidth(buf)/2);
- DrawString(buf);
- sprintf(buf, "Skill level %d", skill);
- GotoLine(9, CENTER - StringWidth(buf)/2);
- DrawString(buf);
- GotoLine(11, CENTER - StringWidth(note1)/2);
- DrawString(note1);
- GotoLine(12, CENTER - StringWidth(note2)/2);
- DrawString(note2);
- GotoLine(13, CENTER - StringWidth(note3)/2);
- DrawString(note3);
-
- if (player[curColor] == Macintosh && nClicks == 0 && !GameOver) {
- TextFont(ChicagoFont);
- clickmessage = isapstr(*GetString(CLICKMESSAGEID));
- MoveTo(BCENTER - StringWidth(clickmessage)/2, BBOTTOM);
- DrawString(clickmessage);
- }
- }
-